//
//  RuleDetailsViewController.m
//  AllFamily
//
//  Created by chirui on 2018/5/29.
//  Copyright © 2018年 Shui. All rights reserved.
//

#import "RuleDetailsViewController.h"

@interface RuleDetailsViewController ()

@end

@implementation RuleDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.barTintColor = NavBackColor;
    self.navigationController.navigationBar.translucent = NO;
    
    [self createUI];
    [self getData];
    
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithIcon:@"icon_nav_renter" target:self action:@selector(backBtnClick)];
}

-(void)backBtnClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)createUI {
    self.navigationItem.titleView = [TopLabel withLabelWithLabelText:@"详情"];
    
    self.webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, screenW, screenH-64)];
    [self.view addSubview:self.webView];
    self.webView.navigationDelegate = self;
}

#pragma mark - 获取地址
- (void)getData {
  
    //    [PostNetWorking postNetWorkingStr:[address_url stringByAppendingString:get_allAppDoc_api] andparameters:dic Success:^(id responseObject) {
    //        if([responseObject[@"code"]intValue] == 200) {
    //            self.url = responseObject[@"datas"][@"url"];
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
    //        }
    //
    //    } failed:^(NSError *error) {
    //        [MBProgressHUD showError:@"网络错误" toView:self.view];
    //    }];
}

#pragma wkwebView navdelegate
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {
    // 开始加载网页
    [MBProgressHUD showMessag:nil withDelay:0 toView:self.view withMode:MBProgressHUDModeIndeterminate hideWithDelay:0];
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    // 成功加载网页
    [MBProgressHUD hideHUDForView:self.view animated:YES];
}
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
    // 加载网页失败
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    [MBProgressHUD showMessag:@"网络错误" withDelay:0 toView:self.view withMode:MBProgressHUDModeText hideWithDelay:1.5];
}


@end
